﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BurnSystems.Gpx
{
    /// <summary>
    /// Stores the properties of a named gpx elements
    /// </summary>
    public abstract class GpxNamedElement
    {
        /// <summary>
        /// Stores the node
        /// </summary>
        protected XElement node;

        /// <summary>
        /// Initializes a new instance of the GpxTrack class.
        /// </summary>
        /// <param name="node">Node to be used for track</param>
        public GpxNamedElement(XElement node)
        {            
            this.node = node;
        }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public string Name
        {
            get
            {
                return this.node.GetElementContent("name", string.Empty);
            }

            set
            {
                this.node.SetElementContent("name", value);
            }
        }

        /// <summary>
        /// Gets or sets the comments
        /// </summary>
        public string Comment
        {
            get
            {
                return this.node.GetElementContent("cmt", string.Empty);
            }

            set
            {
                this.node.SetElementContent("cmt", value);
            }
        }

        /// <summary>
        /// Gets or sets the description
        /// </summary>
        public string Description
        {
            get
            {
                return this.node.GetElementContent("desc", string.Empty);
            }

            set
            {
                this.node.SetElementContent("desc", value);
            }
        }

        /// <summary>
        /// Gets or sets the Source
        /// </summary>
        public string Source
        {
            get
            {
                return this.node.GetElementContent("src", string.Empty);
            }

            set
            {
                this.node.SetElementContent("src", value);
            }
        }
    }
}
